import { _getUserInfo } from '@api/user'
import types from './types'
export default {
  async fetchUserInfo ({commit}) {
    let res = await _getUserInfo()
    if (res.data) {
      // 保存信息到前端
      commit(types.SET_USER_ID, res.data.id)
      commit(types.SET_USER_NAME, res.data.name)
      commit(types.SET_USER_TYPE, res.data.userType)
    }
    return res
  },
  async clearUserInfo ({commit}) {
    commit(types.SET_USER_ID, null)
    commit(types.SET_USER_NAME, null)
    commit(types.SET_USER_TYPE, null)
  }
}
